# -!- coding: utf-8 -!-
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
调用第三方风控服务公司接口，需要传入的post数据
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

from baseset.riskControlApi import API_RISK
import requests
import time

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.80 Safari/537.36',
    'content-Type': 'application/json'
}


def tongDun():
    Api = API_RISK['tongDun']
    partner_code = 'demo'
    partner_key = 'abcd1234566'
    app_name = 'web'
    url = 'https://api.tongdun.cn/bodyguard/apply/v4.5?partner_code=%s&partner_key=%s&app_name=%s' \
          % (partner_code,partner_key,app_name)
    req1 = requests.post(url, json=Api, headers=headers)
    print("（同盾）信贷保镖API返回信息：", req1, req1.text)


def talking():
    Api = API_RISK['talking']
    url = 'https://api.talkingdata.com/data/api/v1/risk/fraudRiskFlat'
    req1 = requests.post(url, json=Api, headers=headers)
    print("TalkingData风险侦测API返回信息：", req1, req1.text)


def tencent():
    secretId = 'AKIDufPRYgmsWyC8NtsRMq3t8CdkGWohJNmE'  # 鉴权密钥
    timestamp = int(time.time())                       # 时间戳
    idNumber = '362422187011084871'
    phone = '13100000000'
    bankCard = '6333380402564890000'
    signature = 'Wn0Wuy3jkncGNvwf485XMxJaVmU%3D'       # 方便后续对账
    url = 'https://csec.api.qcloud.com/v2/index.php?Action=AntiFraud&Nonce=62972&Region=all&SecretId=%s&Timestamp=%s' \
          '&idNumber=%s&phoneNumber=%s&bankCardNumber=%s&Signature=%s'\
          % (secretId,timestamp,idNumber,phone,bankCard,signature)
    req1 = requests.get(url,headers=headers)
    print("天御反欺诈服务API返回信息：", req1, req1.text)


if __name__ == '__main__':
    #tongDun()
    tencent()